// 结构体构造函数
#include <iostream>

typedef struct __test
{
  int i;
  double d;
  char c;
  __test()
  {
    std::cout << "无参" << std::endl;
    // ...设置默认值
    i = 0;
    d = 0;
    c = '\0';
  }
  __test(int _i, double _d, char _c) : i(_i), d(_d), c(_c)
  {
    std::cout << "有参，参数列表使用" << std::endl;
  }
  void init(int _i, double _d, char _c)
  {
    std::cout << "自定义函数" << std::endl;
    this->i = _i;
    this->d = _d;
    this->c = _c;
  }
} test;

int main(void)
{
  test t1;
  test t2(2, 2.1, 'b');
  test t3 = test(3, 3.2, 'c'); // 有参，参数列表使用
  test t4;
  t4.init(4, 4.3, 'd');
  test t5 = {5, 5.4, 'e'}; // 有参，参数列表使用
  // test t5();

  std::cout << "t1 " << t1.i << " " << t1.d << " " << t1.c << std::endl;
  std::cout << "t2 " << t2.i << " " << t2.d << " " << t2.c << std::endl;
  std::cout << "t3 " << t3.i << " " << t3.d << " " << t3.c << std::endl;
  std::cout << "t4 " << t4.i << " " << t4.d << " " << t4.c << std::endl;
  std::cout << "t5 " << t5.i << " " << t5.d << " " << t5.c << std::endl;
  printf("----------------end---------------\n");
  return 0;
}